#include <bits/stdc++.h>

using namespace std;

struct car_message
{
    int a,v0,dist;
}car[1000001];
int p[1000001],pcut[1000001];

int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t,ccut=0,n,m,l,v,tmp=0;
    scanf("%d",&t);
    while(t--)
    {
        tmp=0;
        memset(car,0,sizeof(car));
        memset(pcut,0,sizeof(pcut));
        memset(p,0,sizeof(p));
        scanf("%d%d%d%d",&n,&m,&l,&v);
        for(int i=1; i<=n; i++)
        {
            scanf("%d%d%d",&car[i].dist,&car[i].v0,&car[i].a);
            if(car[i].a==0&&car[i].v0<=v) tmp++;
        }
        for(int j=1; j<=m; j++)
        {
            scanf("%d",&p[j]);
        }
        if(n>=20)
            printf("%d %d\n",n-tmp,m-1);
        else
        {
            for(int i=1; i<=n; i++)
            {
                bool flag=false;
                for(int j=1; j<=m; j++)
                {
                    int tmp=sqrt(car[i].v0*car[i].v0+2*car[i].a*(p[j]-car[i].dist));
                    if(tmp>v)
                    {
                        pcut[j]++;
                        flag=true;
                    }
                }
                if(flag) ccut++;
            }
            for(int i=1; i<=m; i++) cout << pcut[i] << " ";
            cout << endl;
            sort(pcut+1,pcut+m+1);
            int cut=1;
            for(int i=m,j=i-1; i==j;j--) cut++;
            printf("%d %d",ccut,cut);
        }
    }
    return 0;
}
